package com.doudou.collection.adapter.controller;

import com.doudou.collection.domain.service.UserLikeCollectService;
import com.doudou.collection.infrastructure.common.web.ResultVO;
import com.doudou.collection.orm.dto.UserCollectDTO;
import com.doudou.collection.orm.dto.UserLikeDTO;
import com.doudou.collection.orm.entity.UserLiked;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @ClassName UserLikeCollectController<br>
 * @Description 用户点赞收藏<br>
 * @Author 马凯良<br>
 * @Date 2023/6/23 15:02<br>
 * @Version 1.0<br>
 */
@Api(tags = "04.用户点赞收藏模块")
@Slf4j
@RestController
@RequestMapping("/v1/users/")
public class UserLikeCollectController {
    @Autowired
    private UserLikeCollectService userLikeCollectService;

    @PostMapping("{blogId}/like")
    @ApiOperationSupport(order = 10)
    @ApiOperation("用户点赞功能")
    public ResultVO insertUserLiked(@RequestBody UserLikeDTO userLikeDTO, @PathVariable Long blogId){
        log.debug("正在处理用户点赞功能,{}",userLikeDTO);
        String result = userLikeCollectService.userLike(userLikeDTO, blogId);
        return ResultVO.ok(result);
    }
    @PostMapping("{blogId}/collect")
    @ApiOperationSupport(order = 20)
    @ApiOperation("用户收藏功能")
    public ResultVO insertUserCollect(@RequestBody UserCollectDTO userCollectDTO,@PathVariable Long blogId){
        log.debug("正在处理用户收藏功能,{}",userCollectDTO);
        String result = userLikeCollectService.userCollect(userCollectDTO,blogId);
        return ResultVO.ok(result);
    }


}
